﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Services;
using System.Data.Services.Common;
using System.Data.Services.Providers;
using FilmBook.DataServices.PhotoStream;

namespace FilmBook.DataServices
{
    [JsonpSupportBehavior]
    public class FileService : DataService<FilmBookEntities>, IServiceProvider
    {
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
        }

        public object GetService(Type serviceType)
        {
            if (serviceType == typeof(IDataServiceStreamProvider))
                return new PhotoStreamProvider(this.CurrentDataSource);

            return null;
        }
    }
}
